package cn.edu.henu.team.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;

import cn.edu.henu.team.R;
import cn.edu.henu.team.bean.disasterkinds;
import cn.edu.henu.team.bean.drugList;

public class FrugKindsAdapter extends BaseAdapter {
   private Context mcontext;
   private ArrayList<disasterkinds> mlist = new ArrayList<>();
   private TextView tv;
   private TextView sg;
   private LinearLayout mlinear;

   public FrugKindsAdapter(Context mcontext, ArrayList<disasterkinds> mlist) {
      this.mcontext = mcontext;
      this.mlist = mlist;
   }

   @Override
   public int getCount() {
      return mlist.size();
   }

   @Override
   public Object getItem(int position) {
      return mlist.get(position);
   }

   @Override
   public long getItemId(int position) {
      return position;
   }

   @Override
   public View getView(int position, View convertView, ViewGroup parent) {
         convertView = LayoutInflater.from(mcontext).inflate(R.layout.medicine_kinds_item,null);
         tv = convertView.findViewById(R.id.medtv);
         sg = convertView.findViewById(R.id.msg);
         mlinear = convertView.findViewById(R.id.mlinear);
         tv.setText(mlist.get(position).getKind());
      if (mlist.get(position).isSelect()) {
         tv.setTextColor(Color.parseColor("#999999"));
         sg.setVisibility(View.VISIBLE);
         mlinear.setBackgroundColor(Color.parseColor("#88564D"));
      }
      //如果不是选中状态，item字体颜色变黑，红色竖条隐藏，item背景还变灰
      else {
         tv.setTextColor(Color.BLACK);
         sg.setVisibility(View.GONE);
         mlinear.setBackgroundColor(Color.parseColor("#EBEBEB"));
      }

      return convertView;
   }
}
